package com.jcp.controller;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.tags.EscapeBodyTag;

import com.jcp.entity.ExceptionMessage;
import com.jcp.service.EmService;
import com.jcp.util.LayuiData;

/**
 * �쳣�������  ��������
 * @author ������
 *
 */
@Controller
public class EmController {
    
	
	@Autowired
	private EmService esEmService;
	/**
	 * 分页和模糊查询
	 * @param page 页码
	 * @param pageSize  每页显示的记录数
	 * @param carNumber  车牌号用来做车牌的模糊查询
	 * @return
	 */
	@GetMapping(value="selectByPageAndLike" ,produces="application/json;charset=utf-8")
	@ResponseBody
	private LayuiData<ExceptionMessage> selectByPageAndLike(@Param(value="page")int page,int limit,@RequestParam(defaultValue="")String carNumber) {
		LayuiData<ExceptionMessage> layuidata= esEmService.selectEmByPageAndLike(page, limit, carNumber);
		System.out.println("layuidata:"+layuidata.getCount());
		System.out.println("layuidata:"+layuidata.getData());
		return layuidata;
	}
	@PostMapping(value="addEm")
	@ResponseBody
	private boolean addEm(ExceptionMessage exm) {
		
		return esEmService.adadEm(exm);
		
	}
	@PostMapping(value="updateEm")
	@ResponseBody
	private boolean updateEm(ExceptionMessage exm) {
		return esEmService.updateEm(exm);
		
	}
	
	
}
